<div class="row">
	<div class="col-md-12">
		<form id="addForm" class="form-horizontal" action="${request.contextPath}/oms/blog/member/category/add" method="post" onsubmit="return false">
			<div class="box-body" >
				<div class="form-group">
					<label id="blogMemberCategoryNameLabel" for="blogMemberCategoryName" class="col-sm-2 control-label">名称</label>
					<div class="col-sm-10">
						<input type="text" class="form-control" name="name" id="blogMemberCategoryName" placeholder="输入名称...">
					</div>
				</div>
				<div class="form-group">
					<label id="blogMemberCategoryMemberUsernameLabel" for="blogMemberCategoryMemberUsername" class="col-sm-2 control-label">用户名</label>
					<div class="col-sm-10">
						<input type="text" class="form-control" name="username" id="blogMemberCategoryMemberUsername" placeholder="输入用户名...">
					</div>
				</div>
				<div class="form-group">
					<label id="blogMemberCategoryCodeLabel" for="blogMemberCategoryCode" class="col-sm-2 control-label">编码</label>
					<div class="col-sm-10">
						<input type="text" class="form-control" name="code" id="blogMemberCategoryCode" placeholder="输入编码...">
					</div>
				</div>
				<div class="form-group">
					<label id="blogMemberCategorySortOrderLabel" for="blogMemberCategorySortOrder" class="col-sm-2  control-label">排列序号</label>
					<div class="col-sm-4">
						<input  class="form-control" name="sortOrder" id="blogMemberCategorySortOrder" type="number" placeholder="输入排列序号...">
					</div>
					<label id="blogMemberCategoryStatusLabel" for="blogMemberCategoryStatus" class="col-sm-2  control-label">状态</label>
					<div class="col-sm-4">
						<select class="form-control" id="blogMemberCategoryStatus"  name="status" style="width: 100%;" placeholder="选择状态...">
						</select>
					</div>
				</div>
				<div class="form-group">
					<label id="blogMemberCategoryDescriptionLabel" class="col-sm-2 control-label" >描述</label>
					<div class="col-sm-10">
						<input type="text" class="form-control" name="description" id="blogMemberCategoryDescription" placeholder="输入描述...">
					</div>
					</div>
				<div class="form-group">
					<label id="blogMemberCategoryRemarkLabel" class="col-sm-2 control-label">备注</label>
					<div class="col-sm-10">
						<input type="text" class="form-control" name="remark" id="blogMemberCategoryRemark" placeholder="输入备注...">
					</div>
				</div>
				<div class="error-message text-center" id="addFormErrorMsgContainer">
					<span class="error-icon"></span>
					<span id="addFormErrorMsg" class="error-msg" ></span>
				</div>
			</div>
			<div class="box-body">
				<div class="pull-right">
					<button type="submit" class="btn btn-primary btn-sm" ><i class="fa fa-save"></i> 保存</button>
					<button type="button" class="btn btn-default btn-sm" data-dismiss="modal"><i class="fa fa-close"></i> 取消</button>
				</div>
			</div>
		</form>
	</div>
</div>
<script type="text/javascript">
function ajaxSubmit(form) {
	
	var $form = $(form);
	
	if ($form.length === 1 && $form.validate()) {
		$.post(form.action, $form.serialize(),
			function(result) {
				if (result.success) {
					$("#lgModal").modal('hide');
		        	alertMsg(result.message,"success");
		        	dataGridReload();
				} else {
					$form.find(".error-msg").show();
					$form.find(".error-msg").html(result.message);
				}
			}, 'json');
	}
}

$(function() {
    $("#blogMemberCategoryStatus").select2({
        data: StatusStore,
        theme: "bootstrap"
    });
	var $addForm = $("#addForm");
	$addForm.validate({
		rules: {
			name: {
				required: true
			},
            code: {
                required: true
            },
            sortOrder: {
				required: true
			},
            status: {
				required: true
			}
		},
		messages: {
            name:{
				required:"名称不能为空！"
			},
			code:{
                required:"编码不能为空！"
            },
            sortOrder:{
				required:"排列顺序不能为空！"
			},
            status:{
				required:"状态不能为空！"
			}
		},
		submitHandler:ajaxSubmit,
		errorLabelContainer:"#addFormErrorMsgContainer",
		wrapper:"li",
		showErrors:function(errorMap,errorList) {
			if(errorList.length>0){
				$addForm.find(".error-msg").html(errorList[0].message);
			}else{
				$addForm.find(".error-msg").html("");
			}
		},
		onkeyup: false
	});
});
</script>